package com.cycrix.sensor;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.PowerManager;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class SensorActivity extends Activity {
	PowerManager.WakeLock _WakeLock;
	
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        ((Button) findViewById(R.id.btnAccelerometer)).setOnClickListener(new OnClickListener() {			
			public void onClick(View v) {
				Intent intent = new Intent(SensorActivity.this, AccelerometerActivity.class);
				SensorActivity.this.startActivity(intent);
			}
		});
        
        ((Button) findViewById(R.id.btnGyroscope)).setOnClickListener(new OnClickListener() {			
			public void onClick(View v) {
				Intent intent = new Intent(SensorActivity.this, GyroscopeActivity.class);
				SensorActivity.this.startActivity(intent);
			}
		});
        
        ((Button) findViewById(R.id.btnLinearAccelerometer)).setOnClickListener(new OnClickListener() {			
			public void onClick(View v) {
				Intent intent = new Intent(SensorActivity.this, LinearAccelerometerActivity.class);
				SensorActivity.this.startActivity(intent);
			}
		});
        
        ((Button) findViewById(R.id.btnRotationVector)).setOnClickListener(new OnClickListener() {			
			public void onClick(View v) {
				Intent intent = new Intent(SensorActivity.this, RotationVectorActivity.class);
				SensorActivity.this.startActivity(intent);
			}
		});
        
        ((Button) findViewById(R.id.btnTCP)).setOnClickListener(new OnClickListener() {			
			public void onClick(View v) {
				Intent intent = new Intent(SensorActivity.this, TCPActivity.class);
				SensorActivity.this.startActivity(intent);
			}
		});
        
        PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
        _WakeLock = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, "My Tag");
        _WakeLock.acquire();
    }
    
    @Override
    protected void onDestroy() {
    	_WakeLock.release();
    	super.onDestroy();
    }
}